package com.etong.citymap.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.etong.citymap.db.util.CityApplication;

public class SqliteCtrol extends SQLiteOpenHelper {

	public SqliteCtrol(Context context) {
		super(context, CityApplication.DATABASENAME, null, CityApplication.DATABASEVERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase sql) {
		StringBuilder sqlsentence=new StringBuilder();  //案件表
		sqlsentence.append("CREATE TABLE casetable(");
		sqlsentence.append("_id integer primary key autoincrement,");
		sqlsentence.append("Prjid TEXT,"); //案卷标识
		sqlsentence.append("Prjcheckid TEXT,");//处置标识
		sqlsentence.append("Position TEXT,");  //芜湖县（默认）
		sqlsentence.append("Eventtype TEXT,"); //部件类型
		sqlsentence.append("Bigclass TEXT,"); //大类标识
		sqlsentence.append("Smallclass TEXT,"); //小类标识 
		sqlsentence.append("Situation TEXT,");  //描述
		sqlsentence.append("Flag integer,");   //案卷类型 （上报、核查、核实）
		sqlsentence.append("Superid TEXT,");   //用户标识
		sqlsentence.append("Code TEXT,");      //登录标识
		sqlsentence.append("Bgcode TEXT,");    //部件编码
		sqlsentence.append("Objcode TEXT,");   //部件标识
		sqlsentence.append("Communityid TEXT,");  //部件所在社区ID
		sqlsentence.append("Units TEXT,");        //部件所在单元ID
		sqlsentence.append("Xcoor TEXT,");       //经度
		sqlsentence.append("Ycoor TEXT");      //纬度
		sqlsentence.append(")");
		sql.execSQL(sqlsentence.toString());
		
		StringBuilder sqlappendix=new StringBuilder();   //附件表
		sqlappendix.append("CREATE TABLE appendixtable(");
		sqlappendix.append("_id integer primary key autoincrement,");
		sqlappendix.append("path TEXT,"); //附件路径
		sqlappendix.append("state int,");  //附件状态
		sqlappendix.append("caseid int");  //案件id
		sqlappendix.append(")");
		sql.execSQL(sqlappendix.toString());
		
		StringBuilder sqlsinglecall=new StringBuilder();   //单键拨号表
		sqlsinglecall.append("CREATE TABLE appendixtable(");
		sqlsinglecall.append("_id integer primary key autoincrement,");
		sqlsinglecall.append("name TEXT,"); //名称
		sqlsinglecall.append("phone TEXT,");  //号码
		sqlsinglecall.append("createdate timestamp");  //创建时间
		sqlsinglecall.append(")");
		sql.execSQL(sqlsinglecall.toString());

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
